package controller;

import javax.annotation.Resource;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.bind.annotation.RenderMapping;

import service.MovieInfoService;
import domain.Movies;

@Controller
@RequestMapping("VIEW")
public class EditMovieController {

	@RenderMapping(params = "action=editMovie")
	public ModelAndView handleRenderRequestInternal(RenderRequest request,
			RenderResponse response) throws Exception {
		int movieId = Integer.parseInt(request.getParameter("editmovieId"));
		Movies movie = movieInfoService.getMovie(movieId);
		return new ModelAndView("update", "movie", movie);
	}
	
	private MovieInfoService movieInfoService;

	@Resource(name = "movieService")
	@Required
	public void setMovieService(MovieInfoService movieInfoService) {
		this.movieInfoService = movieInfoService;
	}
}
